import axios from "axios";

const baseApi = 'http://101.35.231.245:1073'
//const baseApi = 'http://localhost:1073'

/**
 * @Author 申皓然
 * pickup核心页面
 */

/**
 * 1.0 生成订单编号
 * @param token
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const generateOrderNoGet = (token)=>axios.get(
    baseApi+'/pickup9372/purchase/generateOrderNo',
    {
        headers:{
            Authorization:'Bearer '+token
        }
    })

/**
 * 1.1 发布代买中心（订单）
 * @param token
 * @param requestBody
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const publishCenter = (token, requestBody)=>axios.post(
    baseApi + '/pickup9372/purchase/addPurchaseCenter',
    requestBody,// 将请求体传递给服务器
    {
        headers: {
            Authorization: 'Bearer ' + token
        },
    })

//1.1 发布代买中心 的RequestBody
// const publishCenterRequestBody = ref({
//     //订单编号
//     orderNo: "",
//     //订单价格
//     orderPrice: null,
//     //订单物品名称
//     buyOnBehalf: "",
//     //订单图片url，先调用2.1得到代买中心物品图片地址，再把这个地址传到这里
//     itemPicture: "",
//     //发布者id
//     publishingUserId:null,
//     //填写联系人员姓名，最好先调用根据userId得到user信息，再把姓名和联系方式赋值
//     contactPerson: "",
//     //联系方式
//     contactNumber: "",
//     //购买地址
//     purchaseAddress: "",
//     //送达地址
//     addressForService: ""
// })



/**
 * 2.1 得到代买中心物品图片地址
 * @param token
 * @param orderNo
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const centerImgUrl = (token, orderNo)=>axios.post(
    baseApi + '/hwobs9373/obs/getCenterPicture',
    null,
    {
        headers: {
            Authorization: 'Bearer ' + token
        },
        params:{
            orderNo: orderNo
        }
    }
)


/**
 * 1.2修改代买中心信息
 * @param token
 * @param requestBody
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updatePurchaseCenter = (token, requestBody)=>axios.post(
    baseApi + '/pickup9372/purchase/updatePurchaseCenter',
    requestBody,// 将请求体传递给服务器
    {
        headers: {
            Authorization: 'Bearer ' + token
        },
    })

//1.2修改代买中心信息 的RequestBody
// const updateCenterRequestBody = ref({
//     //代买中心id
//     agencyBuyingCenterId:null,
//     //订单编号
//     orderNo: "",
//     //订单价格
//     orderPrice: null,
//     //订单物品名称
//     buyOnBehalf: "",
//     //订单图片url，先调用2.1得到代买中心物品图片地址，再把这个地址传到这里
//     itemPicture: "",
//     //发布者id
//     publishingUserId:null,
//     //填写联系人员姓名，最好先调用根据userId得到user信息，再把姓名和联系方式赋值
//     contactPerson: "",
//     //联系方式
//     contactNumber: "",
//     //购买地址
//     purchaseAddress: "",
//     //送达地址
//     addressForService: ""
// })

/**
 * 1.3 取消代买中心信息（软删除）
 * @param token
 * @param agencyBuyingCenterId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const cancelPurchaseCenter = (token, agencyBuyingCenterId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingCenterId}/cancelPurchaseCenter`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.3-2删除代买中心信息（前提是软删除）
 * @param token
 * @param agencyBuyingCenterId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deletePurchaseCenter = (token, agencyBuyingCenterId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingCenterId}/deletePurchaseCenter`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};

/**
 * 1.4 普通用户代买中心列表查询
 * @param token
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getCenterList = (token, pageSize, pageNum, centerState, keyword) => {
    return axios.get(
        baseApi + '/pickup9372/purchase/getCenterList',
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
            params: {
                pageSize,
                pageNum,
                centerState,
                keyword,
            },
        }
    );
};

/**
 * 1.4-2 代拿用户查看代买中心列表
 * @param token
 * @param pageSize
 * @param pageNum
 * @param keyword
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getPurchaseCenterList = (token, pageSize, pageNum, keyword) => {
    return axios.get(
        baseApi + '/pickup9372/purchase/getPurchaseCenterList',
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
            params: {
                pageSize,
                pageNum,
                keyword,
            },
        }
    );
};


/**
 * 1.5根据id查看代买中心详细信息（点击表修改）
 * @param token
 * @param agencyBuyingCenterId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getPurchaseCenterById = (token, agencyBuyingCenterId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingCenterId}/getPurchaseCenterById`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};

/**
 * 1.6接单代买中心-将修改订单状态
 * @param token
 * @param agencyBuyingCenterId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addPurchaseOrder = (token, agencyBuyingCenterId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingCenterId}/addPurchaseOrder`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};

/**
 * 1.7取消代买订单
 * @param token
 * @param agencyPurchaseOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const deletePurchaseOrder = (token, agencyPurchaseOrderId,isContact) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyPurchaseOrderId}/deletePurchaseOrder`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
            params: {
                isContact
            },
        }
    );
};


/**
 * 1.8根据id查看代买订单详细信息 -pay_state 支付状态 0未支付，1已支付 2确认支付
 * @param token
 * @param agencyBuyingOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getPurchaseOrderById = (token, agencyBuyingOrderId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingOrderId}/getPurchaseOrderById`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.9 修改代买订单状态 默认没支付-0 发布者-确认支付-2 接收者-说支付-1
 * @param token
 * @param agencyBuyingOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const updatePurchaseOrderPayState = (token, agencyBuyingOrderId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingOrderId}/updatePurchaseOrderPayState`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.10 送达订单 只有接手才能调用这个去送达
 * @param token
 * @param agencyBuyingOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const arrivePurchaseOrder = (token, agencyBuyingOrderId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingOrderId}/arrivePurchaseOrder`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.11 收到订单 只有发布者才能调用这个，表示收到
 * @param token
 * @param agencyBuyingOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const receivePurchaseOrder = (token, agencyBuyingOrderId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingOrderId}/receivePurchaseOrder`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.12 点赞代买中心 点一次换一次状态
 * @param token
 * @param agencyBuyingOrderId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const praisePurchaseCenter = (token, agencyBuyingOrderId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${agencyBuyingOrderId}/praisePurchaseCenter`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.13 新增投诉信息
 * @param token
 * @param requestBody
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addComplaintInformation = (token, requestBody)=>axios.post(
    baseApi + '/pickup9372/purchase/addComplaintInformation',
    requestBody,// 将请求体传递给服务器
    {
        headers: {
            Authorization: 'Bearer ' + token
        },
    })

// //1.13新增投诉信息 的RequestBody
// const addComplaintInformationRequestBody = ref({
//
//     //订单编号
//     orderNo: "",
//     //投诉标题
//     complaintTitle: "",
//     //投诉图片url，先调用2.4得到投诉图片
//     complaintImg: "",
//     //投诉内容
//     complaintContent: "",
//
// })


/**
 * 2.4上传订单投诉照片 得到地址url
 * @param token
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getComplaint = (token) => {
    return axios.get(
        baseApi + '/hwobs9373/obs/getComplaint',
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};


/**
 * 1.14 查看投诉详情
 * @param token
 * @param complaintInformationId
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getComplaintInformationById = (token, complaintInformationId) => {
    return axios.get(
        baseApi + `/pickup9372/purchase/${complaintInformationId}/getComplaintInformationById`,
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
        }
    );
};



/**
 * 1.15 代拿用户查看列表 0已接单1已送达2已收到3已取消4已销毁
 * @param token
 * @param pageSize
 * @param pageNum
 * @param centerState
 * @param keyword
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getOrderList = (token, pageSize, pageNum, orderState, keyword) => {
    return axios.get(
        baseApi + '/pickup9372/purchase/getOrderList',
        {
            headers: {
                Authorization: 'Bearer ' + token,
            },
            params: {
                pageSize,
                pageNum,
                orderState,
                keyword,
            },
        }
    );
};




